$(function () {

    if(sessionStorage.getItem("pageIndex")){
        var pageIndex = sessionStorage.getItem("pageIndex");
        $("#frame").attr("src",pageIndex);
        $("div.nav a.navBtn").each(function(item,index){
            var btnIndex = $(this).attr("index");
            if(btnIndex === pageIndex){
                $(this).addClass("activeNav");
                $(this).siblings().removeClass("activeNav");
            }
        })
    }

    $("div.nav a.navBtn").click(function(){ // 点击导航按钮
         var $this = this;
         goToPage($this);
         switchStyles($this);
    });

    function goToPage($this) {  // 跳转页面方法
        var page = ["admitte.html", "medicalInsurance.html","generalReferral.html","expertInfo.html","expertEgister.html"];
        var currentPage = page[$($this).index()];
        $(this).addClass("current"); $($this).siblings().removeClass("current");
        sessionStorage.setItem("pageIndex", currentPage);
        $("#frame").attr("src", currentPage);
    }

    function switchStyles($this) {  // 导航切换样式方法
        $(".activeNav").removeClass('activeNav');
        $($this).addClass("activeNav");
    }

});